
/**
 * AppleIIGo
 * File Disk Image class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include <stdio.h>
#include "FloppyDiskImage.h"

#ifndef FILEDISKIMAGE_H
#define FILEDISKIMAGE_H

typedef enum {
	FILEDISKTYPE_3_5,
	FILEDISKTYPE_HDD,
};

#define PRODOS_BLOCKBYTENUM		512

class FileDiskImage {
public:
	static FileDiskImage * getInstance(UINT32 diskType,
									   char * diskImagePath);
	
	static bool isDiskImageValid(UINT32 diskType,
								 char * diskImagePath,
								 UINT32 diskImageByteNum);
	
	FileDiskImage(UINT32 diskType, char * diskImagePath,
				  UINT32 diskImageOffset,
				  UINT32 diskImageByteNum,
				  bool isWriteProtectionForced);
	~FileDiskImage();
	
	bool seekBlock(UINT32 blockIndex);
	bool writeBlock(UINT8 * data);
	bool readBlock(UINT8 * data);
	
	bool isOnline();
	bool isWriteProtected();
	UINT32 getBlockNum();
	char * getDiskImagePath();
	
private:
	char * diskImagePath;
	FILE * diskImageFile;
	UINT32 diskImageOffset;
	UINT32 diskImageBlockNum;
	
	bool isWriteProtectedValue;
};

#endif
